package com.bindapp.model;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;

import com.bindapp.R;
import com.bindapp.databinding.ActivityShowstyle2Binding;

/**
 * Created by apple on 2018/7/20.
 */

public class ShowImgStyleModel extends BaseModel {
    private ActivityShowstyle2Binding binding;
    private int select=0;
    private Integer[] selectlist;
    private Integer[] imgs1=new Integer[]{R.drawable.ty_xd1,R.drawable.ty_xd2};
    private Integer[] imgs2=new Integer[]{R.drawable.ty_kt2,R.drawable.ty_kt3};//R.drawable.ty_kt1,
    private Integer[] imgs3=new Integer[]{R.drawable.ty_jd1,R.drawable.ty_jd2,R.drawable.ty_jd3};
    public ShowImgStyleModel(Context context, int type){
        super(context);
        binding=DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.activity_showstyle2,null,false);
        binding.setClick(new ViewClick());
        if(type==0){//现代款
            selectlist=imgs1;
        }else if(type==1){//卡通风
            selectlist=imgs2;
        }else if(type==2){//经典款
            selectlist=imgs3;
        }
        binding.contentimg.setImageDrawable(ContextCompat.getDrawable(context,selectlist[select]));
    }

    @Override
    public ActivityShowstyle2Binding getBinding() {
        return binding;
    }
    public class ViewClick{
        public void onClick(View view){
            switch(view.getId()){
                case R.id.leftbtn:
                    if(select>0){
                        select--;
                    }
                    binding.contentimg.setImageDrawable(ContextCompat.getDrawable(context,selectlist[select]));

                    break;
                case R.id.rightbtn:
                    if(select<(selectlist.length-1)){
                        select++;
                    }
                    binding.contentimg.setImageDrawable(ContextCompat.getDrawable(context,selectlist[select]));
                    break;
            }
        }
    }
}
